//
//  UIButton+FQDExtension.m
//  FakeQDaily
//
//  Created by mewxiv on 8/15/16.
//  Copyright © 2016 Xensius. All rights reserved.
//

#import "UIButton+FQDExtension.h"

@implementation UIButton (FQDExtension)
+ (UIButton *)commentButtonWithCommentNum:(NSInteger)commentNum
{
    UIImage *commentIcon = [UIImage imageNamed:@"feedComment"];
    UIButton *commentButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [commentButton.titleLabel setFont:FQDRegularFontWithSize(12.0f)];
    [commentButton setTitleColor:FQDFeedDetailTextColor forState:UIControlStateNormal];
    [commentButton setTitle:[NSString stringWithFormat:@"%@", @(commentNum)]
                   forState:UIControlStateNormal];
    [commentButton setImage:commentIcon forState:UIControlStateNormal];
    [commentButton setImageEdgeInsets:UIEdgeInsetsMake(0, -2, -1, 2)];
    [commentButton setTitleEdgeInsets:UIEdgeInsetsMake(0, 2, 0, -2)];
    
    return commentButton;
}

+ (UIButton *)praiseButtonWithPraiseNum:(NSInteger)praiseNum
{
    UIImage *praiseIcon = [UIImage imageNamed:@"feedPraise"];
    UIButton *praiseButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [praiseButton.titleLabel setFont:FQDRegularFontWithSize(12.0f)];
    [praiseButton setTitleColor:FQDFeedDetailTextColor forState:UIControlStateNormal];
    [praiseButton setTitle:[NSString stringWithFormat:@"%@", @(praiseNum)]
                  forState:UIControlStateNormal];
    [praiseButton setImage:praiseIcon forState:UIControlStateNormal];
    [praiseButton setImageEdgeInsets:UIEdgeInsetsMake(0, -2, -1, 2)];
    [praiseButton setTitleEdgeInsets:UIEdgeInsetsMake(0, 2, 0, -2)];
    
    return praiseButton;
}

+ (UIButton *)topMenuButtonWithTitle:(NSString *)title iconName:(NSString *)iconName
{
    UIImage *iconImage = [UIImage imageNamed:iconName];
    UIButton *menuButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [menuButton setImage:iconImage forState:UIControlStateNormal];
    [menuButton setTitle:title forState:UIControlStateNormal];
    menuButton.titleEdgeInsets = UIEdgeInsetsMake(0, -35.0f, -42.0f, 0);
    menuButton.imageEdgeInsets = UIEdgeInsetsMake(-23.0f, 0, 0, -4.0f);
    menuButton.titleLabel.font = FQDRegularFontWithSize(14.0f);
    return menuButton;
}

@end
